//
//  fabuTableViewCell.m
//  YeDian
//
//  Created by 罗西 on 3/26/16.
//  Copyright © 2016 罗西. All rights reserved.
//

#import "fabuTableViewCell.h"
#import "UIButton+WebCache.h"
#import "Tools.h"

@implementation fabuTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 40, 15)];
        _dateLabel.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_dateLabel];
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 10, SCREEN_WIDTH-70, 15)];
        _titleLabel.font = [UIFont systemFontOfSize:11];
        [self.contentView addSubview:_titleLabel];
        
    }
    
    return self;
}

-(void)setImageView:(NSArray *)img{
    for (UIView *view in self.contentView.subviews) {
        if ([view isKindOfClass:[UIButton class]]) {
            [view removeFromSuperview];
        }
    }
    float imgW = (SCREEN_WIDTH-40*2-10*2)/3;
    
    for (int i = 0; i<5; i++) {
        
        if (i < img.count) {
            UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(60+(imgW+10)*(i%3), 30+(i/3)*(imgW+10), imgW, imgW)];
            [self.contentView addSubview:btn];
            [btn setImageWithURL:[img objectAtIndex:i] forState:UIControlStateNormal placeholderImage:[UIImage new]];
            btn.backgroundColor = [UIColor lightGrayColor];
            btn.userInteractionEnabled = NO;
        }

    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
